#include "reg52.h"

sbit D1 = P2^0;


void UartInit(void)  //9600bps@11.0592MHz
{
 SCON = 0x50;  
 AUXR &= 0x01;  
 TMOD &= 0x0E;  
 TMOD |= 0x20;  
 TL1 = 0xFD;  
 TH1 = 0xFD;  
 TR1 = 1;  
}

void main()
{
	char cmd;
	UartInit();
  while(1)
  {
		if(RI == 1)
		{
			cmd = SBUF;
			if(cmd == 'O')
			{
				D1 = 0;
			}
			if(cmd == 'C')
			{
				D1 = 1;
			}
			RI = 0;
		}
  }
}